<?php 
include('header.php');
include('menu.php');
error_reporting(E_ALL || E_STRICT);
include('paging_muser/paginator.class.php');
$loginid=$_SESSION['loginid'];
if($_SERVER['HTTP_HOST']=="www.ramkydelhi.com"||$_SERVER['HTTP_HOST']=="ramkydelhi.com")
{
	$conn = new mysqli('localhost', 'ramky123_ramky', 'ramky123','ramky123_ramky') ;
}
else
{
	$conn = new mysqli('localhost', 'root', 'spPRdDCA2m47dmKa','ramky123_ramky') ;
}
$query="SELECT id,name,usertype,loginid,password,emailid,status FROM tbl_dtls_createuser WHERE usertype!='Admin' ";
$recordsPerPage = 50;
if(!empty($_GET['search'])){
	$searchQuery = $_GET['search'];
}

$pageId= intval($_GET['page']);
if (empty($pageId)) {
	$pageId = 1;
}else{
	$pageId = intval($pageId); 
}
// if you are testing it locally uncomment the following line
// to see how it is going to look like
//sleep(2);
$paginator = new Paginator($pageId,$recordsPerPage,$query,$conn);

$paginator->debug = FALSE;

// field(s) to search in
// string or array of fields
$paginator->fields = 'name';
//$paginator->fields = array('name','id');

$paginator->searchQuery = $searchQuery;

// call the core function that paginates
$rows = $paginator->paginate();
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Create User</title>
<link href="css_paging_muser/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js_paging_muser/ajax.js"></script>
<script type="text/javascript" src="js_paging_muser/ajaxUpdater.js"></script> 
<script type="text/javascript" src="js_paging_muser/paginate.js"></script>
</head>
<body>

<div id='search-box' class="search-box" style="padding-right:15px">
<form action="<?=$_SERVER['PHP_SELF']?>" onsubmit='paginate();return false;'>
<?php 
echo parse_str($_SERVER['QUERY_STRING'],$getArray);

foreach($getArray as $key=>$value){

	echo "<input type='hidden' name='{$key}' id='{$key}' value='{$value}' />";
}
?>

<input id="search" type="text" class="search" />
<input type="submit" value="search" class="button" />
</form>
</div>
<div id="listing_container">
<form name="frm1" action="del.php" method="request" id="frm1">
<table  border="0" cellspacing="1"  id="table21" style=" padding:10px" >
<tr><td colspan="9">
</td>
</tr>	
<tr>
<td colspan="9" background="images/title.gif" height="25">
<font face="Verdana" color="#ffffff" style="font-size: 8.5pt"><b>MANAGE USER</b></font></td>
</tr>
												


<tr>
													<td bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Select</font></strong></td>
													<td width="31" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													S.No.</font></strong></td>
													<td width="33" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Name</font></strong></td>
													<td width="58" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													User Type</font></strong></td>
													<td width="46" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Login Id</font></strong></td>
													<td width="47" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Email Id</font></strong></td>
													<td width="21" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Edit</font></strong></td>
													<td width="37" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Delete</font></strong></td>
													<td width="283" height="31" bgcolor="#F0F0F0">
													  <strong><font style="font-size: 8.5pt" face="Verdana" color="#003366">
													Status</font></strong></td>
</tr>
<?php 
$i=1;
foreach($rows as $row)
{
	if($row['status']==1)
	{
		$s ='Active';
	}
	else
	{
		$s = 'Deactive';
	}
?> 
<tr>
<td width="35" height="26" align="center">
<input type="checkbox" name="ids[]" id="ids[]" value="<?php echo "$row[id]";?>"></td>
<td width="31"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><?php echo "$row[id]";?></font></td>
<td width="33"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><?php echo "$row[name]";?></font></td>
<td width="58"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><?php echo "$row[usertype]";?></font></td>
<td width="46"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><?php echo "$row[loginid]";?></font></td>
<td width="47"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><?php echo "$row[emailid]";?></font></td>                                                   
<td width="21" align="center">
<p align="center"><a href="edit_user.php?cid=<?php echo "$row[id]"; ?>">
<img border="0" src="images/edit.png" width="16" height="16"></a></td>
<td width="37" align="center">
<p align="center"><a href="#" onClick="delete_confirm(<?php echo "$row[id]"; ?>)">
<img src="images/b_drop.png" border="0" />
 </a></td>
<td width="283" align="center">
<p align="center"><font style="font-size: 8.5pt" face="Verdana" color="#000000"><a style="text-decoration:none" href="status1.php?id=<?php echo "$row[id] & st=$row[status]";?>"><?php echo $s;?></a></font></td>
</tr>
<?php
$i++;
}
?>
<tr>
<td height="32" colspan="10">

<p align="center">

<input name="checkall" type="button" onClick="checkedAll()" value="Select All" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; "/>&nbsp;
<input type="submit" value="Delete Selected" name="B1" style="border:1px solid #000000; font-size: 8pt; font-family: Verdana; "/>

</table></form>		
													
													

								
					
					
				

<?php
$links = $paginator->getLinks ();
echo "<div class='paginator'> " . $links ;

echo "<p>Page " . $paginator->pageId . " of " . $paginator->totalPages . "</p>";

?>
 </div><!--end of paginator-->
	</div><!--end of listing_container-->
</div><!--end of wrapper-->



</body>
</html>
<?php
if(isset($_GET['B1']))
{
$ids=$_GET['ids'];
//print_r($_GET['ids']);
$i = implode(',',$ids);
//echo $i;
include("../connection/connection.php");
$query = "delete from tbl_dtls_createuser where id in($i)";
//echo $query;exit;
$r = mysql_query($query);
if($r){
	//echo "delete";
	//header('location:inbox.php'); // redirection i.e. move from one page to another.
}
}
?>
<script language='javascript'>
checked=false;
function checkedAll () {
	var aa= document.getElementById('frm1');
	 if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
	for (var i = 0; i < aa.elements.length; i++) 
	{
	 aa.elements[i].checked = checked;
	}
  }
             

 /* var form='frm1'
  function SetChecked(val) {
  dm1=document.forms[form];
  len=dm1.elements.length;
  for(var i=0;i<len;i++)
  {
  dm1.elements[i].checked=val;
  }
  }*/
	  
</script>
<script language='javascript'>

function delete_confirm(id)
{	
	if(confirm('Do you want to Delete if?'))
	{
		//redirection to delete.php script
		document.location='deleteall.php?id='+id; 
	}
	
}
</script>

